// 1.导入http模块
const http = require('http');

//2.创建服务对象
const server = http.createServer((request,response)=>{
    // 获取请求方法
    let {method} = request;
    // 获取url路径
    let {pathname} = new URL(request.url,'http://192.168.101.159');

    // 设置响应头，防止乱码
    response.setHeader('content-type','text/html;charset=utf-8');

    if(method ==='GET' && pathname === '/login'){
        response.end('登录页面');
    }else if(method === 'GET' && pathname ==='/reg') {
        response.end('注册页面');
    }else {
        response.end('Note Found');
    }
})
// 3.监听端口，启动服务
server.listen(9000,()=>{
    console.log('服务已经启动。。。端口9000监听中。。。。');
})

